package com.xiaoyu.merchant.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.xiaoyu.merchant.R;

public class LogOutDialog extends Dialog implements View.OnClickListener {

    private Context mContext;
    private View mContentView;
    private TextView mTxtCancel, mTxtModification;

    public LogOutDialog(Context context) {
        super(context, R.style.BaseDialogStyle);
        this.mContext = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    private void initView() {
        mContentView = LayoutInflater.from(mContext).inflate(R.layout.log_out_dialog, null);
        mTxtCancel = mContentView.findViewById(R.id.cancel);
        mTxtModification = mContentView.findViewById(R.id.confirm);
        mTxtCancel.setOnClickListener(this);
        mTxtModification.setOnClickListener(this);
        setContentView(mContentView);
    }

    @Override
    public void onClick(View v) {
        if (v == mTxtCancel) {
            dismiss();
        }
        if (v == mTxtModification) {//确认退出
            if (listener != null) {
                listener.OnLogOut();
            }
        }
    }

    public ILogOutListener listener;

    public interface ILogOutListener {
        void OnLogOut();
    }

    public void setILogOut(ILogOutListener listener) {
        this.listener = listener;
    }

}
